<%-- 
    Document   : manage_add
    Created on : Oct 22, 2011, 1:37:39 AM
    Author     : Master
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<jsp:include page="/header.jsp"></jsp:include>
<h1>
    Tambah Jadwal Keberangkatan
</h1>
<script type="text/javascript">
    function changeCityFrom(){
        city = $('#sCityFrom').val();
        if(city != 0){
            $('#sPoolFrom').load('./shuttles?action=manage&get=pool&city='+city);
            $('#sCityFrom .defCity').remove();
        }        
    }
    function changeCityTo(){
        city = $('#sCityTo').val();
        if(city != 0){
            $('#sPoolTo').load('./shuttles?action=manage&get=pool&city='+city);
            $('#sCityto .defCity').remove();
        }        
    }
    function changePool(){
        $('.defPool').remove();
    }
</script>
<form action="./shuttles?action=manage&mode=add" method="post" onsubmit="return submit();">
<table id="manageForm">
    <tr>
        <td style="width: 20%;">
            <label for="cityFrom">Kota Keberangkatan :</label>
        </td>
        <td>
            <select id="sCityFrom" name="cityFrom" onchange="changeCityFrom();">
                <option class="defCity" value="0" selected="selected">Pilih Kota Keberangkatan</option>
                <c:forEach items="${cities}" var="city">
                    <option value="${city.getId()}">${city.getName()}</option>
                </c:forEach>
            </select>
        </td>
    </tr>
    <tr>
        <td>
            <label for="poolFrom">Pool Keberangkatan :</label>
        </td>
        <td>
            <select id="sPoolFrom" name="poolFrom" onchange="changePool()">
            </select>
        </td>
    </tr>
    <tr>
        <td style="width: 20%;">
            <label for="cityTo">Kota Tujuan :</label>
        </td>
        <td>
            <select id="sCityTo" name="cityTo" onchange="changeCityTo();">
                <option class="defCity" value="0" selected="selected">Pilih Kota Keberangkatan</option>
                <c:forEach items="${cities}" var="city">
                    <option value="${city.getId()}">${city.getName()}</option>
                </c:forEach>
            </select>
        </td>
    </tr>
    <tr>
        <td>
            <label for="poolTo">Pool Tujuan :</label>
        </td>
        <td>
            <select id="sPoolTo" name="poolTo" onchange="changePool()">
            </select>
        </td>
    </tr>
    <tr>
        <td>
            <label for="shuttle">Jenis Kendaraan :</label>
        </td>
        <td>
            <select name="shuttle">
                <c:forEach items="${shuttles}" var="shuttle">
                    <option value="${shuttle.getId()}">${shuttle.getName()}</option>
                </c:forEach>
            </select>
        </td>
    </tr>
    <tr>
        <td>
            <label>Hari Keberangkatan :</label>
        </td>
        <td>
            <table>
                <tr>
                    <td>
                        <input type="checkbox" name="day[]" value="1"/> Sunday
                    </td>
                    <td>
                        <input type="checkbox" name="day[]" value="2"/> Monday
                    </td>
                    <td>
                        <input type="checkbox" name="day[]" value="3"/> Tuesday
                    </td>
                    <td>
                        <input type="checkbox" name="day[]" value="4"/> Wednesday
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="day[]" value="5"/> Thursday
                    </td>
                    <td>
                        <input type="checkbox" name="day[]" value="6"/> Friday
                    </td>
                    <td>
                        <input type="checkbox" name="day[]" value="7"/> Saturday
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td>
            <label for="hour">Jam Keberangkatan :</label>
        </td>
        <td>
            <select name="hour">
                <%
                    for(int i=0;i<24;i++){
                        out.println("<option value=\""+String.format("%02d", i) +":00:00\">"+String.format("%02d", i)+":00</option>");
                    }
                %>
            </select>
        </td>
    </tr>
    <tr>
        <td>
            <label for="fare">Harga Tiket :</label>
        </td>
        <td>
            <input type="text" name="fare" />
        </td>
    </tr>
    <tr>
        <td colspan="2">
            <input type="submit" value="Submit" />
        </td>
    </tr>
</table>
</form>
<jsp:include page="/footer.jsp"></jsp:include>
